import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public class Test {
    public static void main(String[] args) {
        Solution solution = new Solution();
        System.out.println(solution.lengthOfLongestSubstring("abcabcbb"));
    }
}
,3

class Solution {
    int left = 0,right = 0;
    int count = 0;//长度计数
    Map<Character,Integer> set = new HashMap<>();//不重复的存放字符串中的字符
    public int lengthOfLongestSubstring(String s) {
        //


        for(right=0;right<s.length();right++){
            char c = s.charAt(right);
            Integer ret = set.put(c,right);//能放进去，返回null，表示之前没有
            while(ret!=null){
                set.remove(s.charAt(left));
                left++;
                ret = set.put(c,right);
            }

            count = Math.max(count,right-left+1);

        }
        return count;


    }
}